<!DOCTYPE html>
<html lang="ch-ZN">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
</head>

<body>
<table>
    <tr>
        <td>编号:</td>
        <td><input type="text" id="id"></td>
    </tr>
    <tr>
        <td>用户名:</td>
        <td><input type="text" id="name"></td>
    </tr>
    <tr>
        <td>密码:</td>
        <td><input type="text" id="author"></td>
    </tr>

    <tr>
        <td ><input type="button" onclick="javascript:history.go(-1)" value="返回"></td>
        <td ><input type="button" onclick="go();" value="提交"></td>
    </tr>
</table>
<script>
    function go() {
        var ajax=new XMLHttpRequest();
        var id=document.getElementById("id").value;
        var name=document.getElementById("name").value;
        var author=document.getElementById("password").value;
        ajax.open("post","/UserMapper.do",true);
        ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        ajax.send("id="+id+"&name="+name+"&author="+author+"&price="+price)
        ajax.onreadystatechange=function () {
            if(ajax.readyState==4&&ajax.status==200){
                alert(ajax.responseText);
                if(ajax.responseText=="添加成功"){
                    window.location.href="index.jsp";
                }

            }
        }
    }

</script>
</body>
</html>
